<?php

class Message {
	private $id;
	private $title;
	
	function __construct($id,$title){
		$this -> id = $id;
		$this -> title = $title;
	}
	
	
	function getMessage($db,$id){
		$result=$db->query("SELECT * FROM message WHERE mes_IDmessage = $id",2);
		$message=new Message($result[0]['mes_IDmessage'],
						$result[0]['mes_title']);
				
		return $message;
	
	}
	
	function insertMessage($db,$message){
		$description 	= $message -> getDescription();
		$result=$db->insert("INSERT INTO message (mes_description) VALUES('$description'");
		return $result;
	}	
	
	function deleteMessage($db,$message){
		$id 			= $message -> getID();
		$result=$db->delete("DELETE FROM message WHERE mes_IDmessage = " . $id);
		return $result;
	}	
	
	function updateMessage($db,$message){
		$id 			= $message -> getID();
		$description	= $message -> getDescription();
		$result=$db->update("UPDATE message SET mes_description='$description' WHERE mes_IDmessage = " . $id);
		return $result;
	}		
	
	function getID(){
		return $this -> id;
	}
	
	function  setID($id){
		$this -> id = $id;
																																																																																																																																																																																																																																																																																																																			}
																																																																																																																																																																																																																																																																																																																			
																																																																																																																																																																																																																																																																																																																			function getTitle(){
																																																																																																																																																																																																																																																																																																																				return $this -> title;
																																																																																																																																																																																																																																																																																																																			}
																																																																																																																																																																																																																																																																																																																			
																																																																																																																																																																																																																																																																																																																			function  setTitle($title){
		$this -> title = $title;
	}
}

?>